home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / os2 / bbs102d.zip / install.cmd < prev   
OS/2 REXX Batch file  |  1997-03-29  |  15KB  |  495 lines

  1. /* this is the BBS-addon for  SRE-FILTER installation program */
  2.  
  3. /* Load up advanced REXX functions */
  4. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  5. call SysLoadFuncs
  6.  
  7. /*---- load the rexxlib library */
  8. droprxlib=0 ; gotrxlib=1
  9. foo=rxfuncquery('rexxlibregister')
  10. if foo=1 then do
  11.  droprxlib=1 ; gotrxlib=0
  12.  call rxfuncadd 'rexxlibregister','rexxlib', 'rexxlibregister'
  13.  call rexxlibregister
  14. end
  15. foo=rxfuncquery('rexxlibregister')
  16. if foo=1 then do
  17.     say " Could not find the REXXLIB procedure library (REXXLIB.DLL). "
  18.     say "  Did you download it? "
  19.     exit
  20. end  /* Do */
  21.  
  22. crlf='0d0a'x
  23.  
  24. ansion=checkansi()
  25. if ansion=1 then do
  26.   aesc='1B'x
  27.   cy_ye=aesc||'[37;46;m'
  28.   normal=aesc||'[0;m'
  29.   bold=aesc||'[1;m'
  30.   re_wh=aesc||'[31;47;m'
  31.   reverse=aesc||'[7;m'
  32. end
  33. else do
  34.   say " Warning: Could not detect ANSI....  Install will look ugly ! "
  35.   parse pull .
  36.   cy_ye="" ; normal="" ; bold="" ;re_wh="" ;
  37.   reverse=""
  38. end  /* Do */
  39.  
  40. cls
  41. say  " " ; say
  42.  
  43. call lineout, bold cy_ye
  44. call lineout, "This is the BBS addon for SRE-FILTER  installation program (2/97).     "
  45. call lineout, normal
  46.  
  47. say " This program will ask for the names of a few directories,"
  48. say " and will copy a number of files to these directories."
  49. say "  "
  50.  
  51. if yesno(" Are you ready to continue ")=1 then
  52.  nop
  53. else do
  54.  say " See you later?.. "
  55.  exit
  56. end
  57.  
  58.  
  59. nowdir=directory()
  60. deffil=filespec('d',nowdir)||'\BBSFILES'
  61.  
  62. godir=filespec('d',deffil)||'\GOSERVE'
  63. webdir=filespec('d',deffil)||'\WWW'
  64.  
  65.  
  66. gunky1:
  67. say " "
  68. call charout,  bold " Enter the  root of your BBS-Files directory " normal crlf
  69. call charout,"  ENTER= " deffil  " ? "
  70. parse pull afile_dir
  71. if afile_dir="" then afile_Dir=deffil
  72. afile_dir=strip(afile_dir,'t','\')
  73. foo=dosisdir(afile_dir)
  74. if foo=0 then do
  75.     say " Could not find directory: " afile_dir
  76.     signal gunky1
  77. end
  78.  
  79. gunky2:
  80. say " "
  81. call charout,  bold " Enter the GoServe working directory (that contains SREFILTR.80)" normal crlf
  82. call charout,"  ENTER= " godir  " ? "
  83. parse pull work_dir
  84. if work_dir="" then work_Dir=godir
  85. work_dir=strip(work_dir,'t','\')
  86. foo=dosisdir(work_dir)
  87. if foo=0 then do
  88.     say " Could not find directory: " work_dir
  89.     signal gunky2
  90. end
  91. foo=work_dir||'\SREFILTR.80'
  92. if stream(foo,'c','query exists')=' ' then do
  93.    say " Could not find SREFILTR.80.  Please reenter "
  94.    signal gunky2
  95. end  /* Do */
  96.  
  97. gunky3:
  98. say " "
  99. call charout,  bold " Enter the  GoServe data directory (that contains your home page)" normal crlf
  100. call charout,"  ENTER= " webdir  " ? "
  101. parse pull web_dir
  102. if web_dir="" then web_Dir=webdir
  103. web_dir=strip(web_dir,'t','\')
  104. foo=dosisdir(web_dir)
  105. if foo=0 then do
  106.     say " Could not find directory: " web_dir
  107.     signal gunky3
  108. end
  109.  
  110. gunky4:
  111. say " "
  112. /* check /imgs */
  113. imgdir=web_dir||'\IMGS'
  114. foo=dosisdir(imgdir)
  115. if foo=0 then do
  116.    say " Could not find " imgdir
  117.    call charout,  bold " Enter the  SRE-Filter /IMGS directory" normal crlf
  118.    call charout,"   ? "
  119.    parse pull imgdir
  120.    imgdir=strip(imgdir,'t','\')
  121.    foo=dosisdir(imgdir)
  122.    if foo=0 then do
  123.     say " Could not find directory: " imgdir
  124.     signal gunky4
  125.   end
  126.   say "Note: you will have to set IMAGEPATH='"|| imgdir ||"'(in BBS.INI) "
  127. end
  128.  
  129.  
  130. bbdir=work_dir||'\bbsdata'
  131.  
  132. say " --------------- "
  133. say " This installation program will install files to " bbdir
  134. say " and to several subdirectories under BBSDATA\.  You can change this by "
  135. say " editing BBS.INI (but I'm  not sure why you'ld want to). "
  136. say " It will also copy a few .HTM (HTML) files to " web_dir
  137. say " "
  138.  
  139. if yesno(" Are you ready to copy the files ")=0 then do
  140.    say " Okay, you can try again later "
  141.    exit
  142. end  /* Do */
  143.     
  144. say "Modifying the BBS.INI file "
  145. goo=charin("BBS.INI",1,chars('bbs.ini'))
  146. aa=stream("BBS.INI",'c','close')
  147.  
  148. todo="file_dir='"||afile_dir||"' "
  149. agoo=pos("file_dir='\BBSFILES'",goo)
  150.  
  151. goo=replacestrg(goo,"file_dir='\BBSFILES'",todo,'ALL')
  152.  
  153. lm="LAST_MODIFIED='"||time('n')' 'date('n')"'"
  154. goo=replacestrg(goo,"LAST_MODIFIED=' '",lm)
  155.  
  156. say " Copying BBS.INI"
  157. t=stream(work_dir||'\BBS.INI','c','query exists')
  158. bbsinifile=t
  159. if t<>" " then do
  160. SAY  REVERSE " -------------------- " NORMAL
  161.  Say " A copy of BBS.INI exists in " work_dir
  162. say " "
  163. say bold "Note to upgraders:" normal " If you are upgrading BBS, we recommend "
  164. say      "                      that you do" bold "not" normal " overwrite BBS.INI. "
  165. say " "
  166.  oo=yesno(" Are you sure you want to overwrite this BBS parameters file ?")
  167.  if oo=1 then do
  168.       arf=dostempname(work_dir||"\BBSINI.???")
  169.       foo=dosrename(t,arf)
  170.       if foo=0 then do
  171.           say " Error renaming " t " to " arf
  172.           exit
  173.       end  /* Do */
  174.       else do
  175.            say " Old copy of BBS.INI moved to " arf
  176.       end  /* Do */
  177.       foo=charout(t,goo,1)
  178.       if foo>0 then do
  179.           say " error writing BBS.INI " foo
  180.           exit
  181.       end  /* Do */
  182.    end  /* Do */
  183.    else do
  184.       say " Old BBS.INI is retained "
  185.    end
  186. SAY  REVERSE " -------------------- " NORMAL
  187.  
  188. end
  189. else do
  190.       foo=charout(work_dir||'\BBS.INI',goo,1)
  191.       bbsinifile=work_dir'\bbs.ini'
  192. end
  193. say " "
  194. say " Copying  BBS.CMD and other stuff to " work_dir
  195. foo=check_copy('BBS.CMD',work_dir,' Are you sure (this is the main BBS program file)')
  196. foo=check_copy('BBSCACHE.CMD',work_dir,,1)
  197. foo=check_copy('BBSCONFG.CMD',work_dir,,1)
  198. foo=check_copy('BBSRECNT.CMD',work_dir,' Are you sure (this is the BBS  recent file lister)',1)
  199. foo=check_copy('BBSUP.CMD',work_dir,,1)
  200. foo=check_copy('BBSNEWU.CMD',work_dir,,1)
  201.  
  202. foo=check_copy('BBSHELLO.HTM',web_dir,' Are you sure (this is the BBS "welcome" screen)')
  203. foo=check_copy('BBSLOGON.HTM',web_dir,'Are you sure (this is the BBS "prompt for username/password screen)')
  204. foo=check_copy('BBSUP.HTM',web_dir,'Are you sure (this is the BBS "upload instructions" screen)')
  205. foo=check_copy('BBSNEWU.HTM',web_dir,'Are you sure (this is the BBS "new user registration" screen)')
  206. foo=check_copy('BBSPLAY.HTM',web_dir,' Are you sure (this is the BBS "play with options" front-end)')
  207. foo=check_copy('BBS1A.HTM',web_dir,' Are you sure (this is the first part of the "alternative BBS welcome" screen)')
  208. foo=check_copy('BBS1B.HTM',web_dir,' Are you sure (this is the last  part of the "alternative BBS welcome" screen)')
  209.  
  210.  
  211. say " " ; say " Copy BBS manual (BBS.DOC) to " web_dir
  212. foo=check_copy('BBS.DOC',web_dir,,1)
  213.  
  214. foo=check_copy('*.gif',imgdir,,1)
  215.  
  216. /* create bbsdata directories */
  217. isnew=directory(bbdir)
  218. if isnew="" then do
  219.    say " Creating: " bbdir
  220.    oo=sysmkdir(bbdir)
  221.   if oo=0  then do
  222.           say "      Directory created: " bbdir
  223.   end
  224.   else do
  225.            say "      Could not create " bbdir "(error = " oo
  226.            exit
  227.   end
  228. end
  229. foo=directory(nowdir)
  230. say " "
  231. say " copying generic header, footer, etc. files "
  232. foo=check_copy('BBS.HDR',bbdir,' Are you sure (this is the generic header)')
  233. foo=check_copy('BBS.FTR',bbdir,' Are you sure (this is the generic footer)')
  234. foo=check_copy('BBSZIP.HDR',bbdir,' Are you sure (this is the generic  .ZIP header)')
  235. foo=check_copy('BBS.CTL',bbdir,' Are you sure (this is the access control file)')
  236. foo=check_copy('BBS.EXC',bbdir,' Are you sure (this is the generic exclusion file)')
  237. foo=check_copy('BBS.DSC',bbdir,' Are you sure (this is the generic file-descriptions file)')
  238. foo=check_copy('FILES.BBS',bbdir,' Are you sure (this is the sample inclusion mode file)')
  239.  
  240.  
  241.  
  242. /* create bbsdata directories */
  243. udir=bbdir"\USERLOG"
  244. isnew=directory(udir)
  245. if isnew="" then do
  246.    say " Creating: " udir
  247.    oo=sysmkdir(udir)
  248.   if oo=0  then
  249.           say "      Directory created: " udir
  250.   else do
  251.            say "      Could not create " udir "(error = " oo
  252.            exit
  253.   end
  254. end
  255.  
  256. say " Copying bbsstat.cmd to  " udir
  257. foo=check_copy('BBSSTAT.CMD',strip(udir,'t','\')'\',,1)
  258.  
  259. say " .......... "
  260. /* create bbsdata directories */
  261. udir=bbdir"\UPLOAD"
  262. isnew=directory(udir)
  263. if isnew="" then do
  264.    say " Creating: " udir
  265.    oo=sysmkdir(udir)
  266.   if oo=0  then
  267.           say "      Directory created: " udir
  268.   else do
  269.            say "      Could not create " udir "(error = " oo
  270.            exit
  271.   end
  272. end
  273.  
  274.  
  275. /* create bbsdata directories */
  276. udir=bbdir"\CACHE"
  277. isnew=directory(udir)
  278. if isnew="" then do
  279.    say " Creating: " udir
  280.    oo=sysmkdir(udir)
  281.   if oo=0  then
  282.           say "      Directory created: " udir
  283.   else do
  284.            say "      Could not create " udir "(error = " oo
  285.            exit
  286.   end
  287. end
  288.  
  289. foo=directory(nowdir)
  290.  
  291. say reverse " ------------------------------------------------- "normal
  292. say bold " The BBS files and directories have been created. " normal
  293. say" "
  294. say bold "*" normal " You should now edit " bbsinifile
  295. say      "    -- or read the documentation file (" web_dir||"\BBS.DOC) "
  296. say      "    -- or run the BBS Configurator (/BBSCONFG?) "
  297.  
  298. say " "
  299. say bold "*" normal " The following lines "bold"must"normal" be in your ALIASES.IN file:"
  300. say "         bbs/download/*  bbs?download=* "
  301. say "         bbs/zipdownload/*  bbs?zipdownload=* "
  302. say "     (if they aren't in ALIASES.IN, you" bold "must"normal" add them) "
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311. exit
  312.  
  313. /* ------------------------------------------------------------------ */
  314.  /* function: Check if ANSI is activated                               */
  315.  /*                                                                    */
  316.  /* call:     CheckAnsi                                                */
  317.  /*                                                                    */
  318.  /* where:    -                                                        */
  319.  /*                                                                    */
  320.  /* returns:  1 - ANSI support detected                                */
  321.  /*           0 - no ANSI support available                            */
  322.  /*          -1 - error detecting ansi                                 */
  323.  /*                                                                    */
  324.  /* note:     Tested with the German and the US version of OS/2 3.0    */
  325.  /*                                                                    */
  326.  /*                                                                    */
  327.  CheckAnsi: PROCEDURE
  328.    thisRC = -1
  329.  
  330.    trace off
  331.                          /* install a local error handler              */
  332.    SIGNAL ON ERROR Name InitAnsiEnd
  333.  
  334.    "@ANSI 2>NUL | rxqueue 2>NUL"
  335.  
  336.    thisRC = 0
  337.  
  338.    do while queued() <> 0
  339.      queueLine = lineIN( "QUEUE:" )
  340.      if pos( " on.", queueLine ) <> 0 | ,                       /* USA */
  341.         pos( " (ON).", queueLine ) <> 0 then                    /* GER */
  342.        thisRC = 1
  343.    end /* do while queued() <> 0 */
  344.  
  345.  InitAnsiEnd:
  346.  signal off error
  347.  RETURN thisRC
  348.  
  349.  
  350. /* -------------------- */
  351. /* get a yes or no , return 1 if yes */
  352. yesno:procedure expose normal reverse bold
  353. parse arg fooa , allopt,altans
  354. if altans<>" " & words(altans)>1 then do
  355.    w1=strip(word(altans,1))
  356.    w2=strip(word(altans,2))
  357.    a1=left(w1,1) ; a2=left(w2,1)
  358.    a1a=substr(w1,2) ; a2a=substr(w2,2)
  359. end
  360. else do
  361.     a1='Y' ; a1a='es'
  362.     a2='N' ; a2a='o'
  363. end  /* Do */
  364. ayn='  '||bold||a1||normal||a1a||'\'||bold||a2||normal||a2a
  365. if allopt=1 then  ayn=ayn||'\'||bold||'A'||normal||'ll'
  366.  
  367. do forever
  368.  foo1=normal||reverse||fooa||normal||ayn
  369.  call charout,  foo1 normal ':'
  370.  pull anans
  371.  if abbrev(anans,a1)=1 then return 1
  372.  if abbrev(anans,a2)=1 then return 0
  373.  if allopt=1 & abbrev(anans,'A')=1 then return 2
  374. end
  375.  
  376.  
  377. /* ------------- */
  378. /* ----------------------------------------------------------------------- */
  379. /* REPLACESTRG: In string astring, find first occurence substring target and
  380. .   replace it with substring putme
  381. .      if no target, return unchanged astring
  382. .      if no putme, then remove target
  383. .      if type=backward, then find/change LAST occurence
  384. .      if type=all, find/change all occurences
  385. .      if exactmatch=yes, then do not capitalize during search (exact match only */
  386. /* ----------------------------------------------------------------------- */
  387.  
  388. replacestrg: procedure
  389.  
  390. exactmatch=0
  391. backward=0 ; doall=0
  392.  
  393. parse arg astring ,  target   , putme , type , exactmatch
  394.  
  395. type = translate(type)
  396. if type="BACKWARD" then backward="YES"
  397. if type="ALL" then doall="YES"
  398.  
  399. iat=1
  400. joelen=length(target)
  401. joelen2=length(putme)
  402.  
  403. doagain:                /* here if doall=yes */
  404.  if exactmatch="YES" then do
  405.     if   backward="YES" then
  406.         joe= lastpos(target,astring)
  407.     else
  408.         joe= pos(target,astring,iat)
  409.  end
  410.  else do
  411.    if   backward="YES" then
  412.         joe= lastpos(translate(target),translate(astring))
  413.     else
  414.         joe= pos(translate(target),translate(astring),iat)
  415.  end
  416.  if joe=0 then
  417.          return astring
  418.  
  419.  astring=delstr(astring,joe,joelen)
  420.  if putme<>' ' then
  421.     astring=insert(putme,astring,joe-1)
  422.  
  423.  if doall="YES" then do
  424.      iat=joe+joelen2
  425.      signal doagain
  426.  end
  427. /* else, all done */
  428.  return astring
  429.  
  430. /*******************************************/
  431. /* check for existence of file, then ask user to copy or not */
  432. /* note that for X.* type copies, it only checks once
  433.    (not for each file, but just for any one of them */
  434. /********************************************/
  435. check_copy: procedure expose copyall reverse bold normal
  436. parse arg file1, dest1 , amess , noask
  437.  
  438. dest2=strip(dest1,'t','\')||'\'
  439.  
  440. filename=dest2||file1
  441.  
  442.  
  443. if copyall=1 then signal doit3
  444.  
  445.  
  446. aa=sysfiletree(filename,isit,'F')
  447.  
  448. ok=1
  449. if aa<>0 then do
  450.    say " Warning: error when looking for pre-existing copy of: " filename
  451.    ok=yesno(" Do you want to copy this file (or files) anyways? ")
  452.    if ok=1 & amess<>""  then
  453.       ok=yesno(amess)
  454. end
  455.  
  456. if noask=1 then signal doit3
  457.  
  458. if isit.0>0 then do
  459.   if pos('*',file1)=0 then do
  460.       say " "
  461.       say " A file exists with the name: " filename
  462.       ok=yesno(" Do you want to overwrite this file? ",1)
  463.       if ok=1 & amess<>""  then
  464.            ok=yesno(amess)
  465.   end
  466.   else do
  467.     say " "
  468.       say " There is at least one file that matches: " filename
  469.       say "  (this match may " bold " not " normal " be one of the files that will be copied!) "
  470.       ok=yesno(" Do you want to copy these files? ",1)
  471.       if ok=1 & amess<>""  then
  472.            ok=yesno(amess)
  473.   end  /* Do */
  474.  
  475. end
  476.  
  477. if ok=2 then do
  478.   say " "
  479.   say "SRE-FILTER will overwrite all files (not just these) "
  480.   copyall=yesno(" Are you sure you want to do this?")
  481.   if copyall=0 then
  482.       ok=yesno(" Do you want to overwrite the current file (or files)? ")
  483. end
  484.  
  485. if ok=0  then return 0
  486.  
  487. doit3:          /* jump here if copyall is on, or noask=1 */
  488. '@COPY ' file1 dest1 ' > NUL '
  489.  
  490. return 1
  491.  
  492.  
  493.  
  494.  
  495.